//
//  HJCompletAirPortVC.m
//  project
//
//  Created by hu on 2019/4/9.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJCompletAirPortVC.h"
#import "HJCompletTicketView.h"
#import "HJTeamHeader.h"
#import "HJTicketView.h"
#import "HJAuthenticationVC.h"
#import "HJBuyTicketVC.h"
@interface HJCompletAirPortVC ()
@property (nonatomic,strong) HJTeamHeader * teamHeader;
@property (nonatomic,strong) HJCompletTicketView *completAirportView;
@property (nonatomic,strong) HJTicketView * ticketView;
@property (nonatomic,strong) HJAuthenticationVC * authVC;
@end

@implementation HJCompletAirPortVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navTitle = @"完成组队详情";
    [self configBtmViewBtn];
}
-(HJTicketView *)ticketView {
    if (!_ticketView) {
        _ticketView = [[HJTicketView alloc]init];
        _ticketView.frame = CGRectMake(0, CGRectGetMaxY(self.completAirportView.frame), SCREEN_WIDTH, 288);
    }
    return _ticketView;
}
-(HJAuthenticationVC *)authVC {
    if (!_authVC) {
        _authVC = [[HJAuthenticationVC alloc]init];
        _authVC.view.frame = CGRectMake(0, SCREEN_HEIGTH, SCREEN_WIDTH, SCREEN_HEIGTH);
        WS(weakSelf);
        _authVC.removeBlock = ^{
            [UIView animateWithDuration:0.5 animations:^{
                weakSelf.authVC.view.frame = CGRectMake(0, SCREEN_HEIGTH, SCREEN_WIDTH, SCREEN_HEIGTH);
            } completion:^(BOOL finished) {
                weakSelf.authVC = nil;
            }];
        };
        [[UIApplication sharedApplication].keyWindow addSubview:_authVC.view];
    }
    return _authVC;
}
-(void)configTableView {
    self.tableViewStyle =UITableViewStylePlain;
    [super configTableView];
    self.tableView.tableHeaderView = [self configTableHeaderView];
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 68, 0);
}
-(UIView *)configTableHeaderView {
    UIView * tableHeader = [UIView new];
    tableHeader.frame = CGRectMake(0, 0, SCREEN_WIDTH, 278+300+288);
    
    HJTeamHeader * teamHeader = [[HJTeamHeader alloc]init];
    teamHeader.frame = CGRectMake(0, 0, SCREEN_WIDTH, 278);
    self.teamHeader = teamHeader;
    [tableHeader addSubview:teamHeader];
    
    HJCompletTicketView * airPortTicketView = [[HJCompletTicketView alloc]init];
    airPortTicketView.frame = CGRectMake(0, teamHeader.height, SCREEN_WIDTH, 300);
    self.completAirportView = airPortTicketView;
    WS(weakSelf)
    airPortTicketView.ticketBtnClickedBlock = ^{
        HJBuyTicketVC * buybusTicket = [[HJBuyTicketVC alloc]init];
        [weakSelf.navigationController pushViewController:buybusTicket animated:YES];
//        [UIView animateWithDuration:0.5 animations:^{
//            weakSelf.authVC.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH);
//        }];
    };
    [tableHeader addSubview:airPortTicketView];
    
    [tableHeader addSubview:self.ticketView];
    
    return tableHeader;
}

-(void)configBtmViewBtn {
    CGFloat btnY = self.view.height - Height_TabBar-68;
    UIButton *releaseButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    releaseButton.frame = CGRectMake(48, btnY, SCREEN_WIDTH - 96, 68);
    [releaseButton setBackgroundImage:[UIImage imageNamed:@"releasebtn"] forState:(UIControlStateNormal)];
    [releaseButton setTitle:@"和TA聊天" forState:(UIControlStateNormal)];
    releaseButton.adjustsImageWhenHighlighted = NO;
    releaseButton.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    releaseButton.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 8, 0);
    [releaseButton addTarget:self action:@selector(completButtonClicked) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:releaseButton];
    
}

-(void)completButtonClicked {
    
}
@end
